﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Leo.Awesome.AppPlatform.Dtos;
using Leo.Awesome.AppPlatform.Services;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
using static Leo.Awesome.AppPlatform.AppPlatfromApplcationContractsConsts;
namespace Leo.Awesome.AppPlatform.Controllers
{
    [Area(ModuleName)]
    [RemoteService(Name = RemoteServiceName)]
    [Route("api/[controller]")]
    [SwaggerTag("菜单管理")]
    public class MenuManagementController : AbpControllerBase, IMenuAppService
    {
        private readonly IMenuAppService MenuAppService;

        public MenuManagementController(IMenuAppService MenuAppService)
        {
            this.MenuAppService = MenuAppService;
        }


        [HttpPost("")]
        [SwaggerOperation(
          Summary = "创建",
          Description = "",
          OperationId = "",
          Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusCreate)]
        public async Task<MenuGetOutPutDto> CreateAsync(MenuCreateUpdateInput input)
        {
            return await MenuAppService.CreateAsync(input);
        }

        [HttpPost("Delete/{id}")]
        [SwaggerOperation(
         Summary = "删除",
         Description = "",
         OperationId = "",
         Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusDelete)]
        public async Task DeleteAsync(Guid id)
        {
            await MenuAppService.DeleteAsync(id);
        }

  
        [HttpGet("Get/{id}")]
        [SwaggerOperation(
         Summary = "查询",
         Description = "",
         OperationId = "",
         Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusView)]
        public async Task<MenuGetOutPutDto> GetAsync(Guid id)
        {
            return await MenuAppService.GetAsync(id);
        }

        [HttpPost("GetList")]
        [SwaggerOperation(
             Summary = "分页查询列表",
             Description = "",
             OperationId = "",
             Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusView)]
        public async Task<PagedResultDto<MenuGetListOutputDto>> GetListAsync(MenuGetListInput input)
        {
            return await MenuAppService.GetListAsync(input);
        }

     

        [HttpPost("getTree")]
        [SwaggerOperation(
            Summary = "获取树列表",
            Description = "",
            OperationId = "",
            Tags = new[] { "MenuManagement" }
        )]
        public async Task<List<MenuTreeOutput>> GetTree(MenuTreeInput input)
        {
            return await MenuAppService.GetTree(input);
        }

        [HttpPost("Query")]
        [SwaggerOperation(
          Summary = "查询列表",
          Description = "",
          OperationId = "",
          Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusView)]
        public async Task<List<MenuGetListOutputDto>> Query(MenuGetListInput getListInput)
        {
            return await MenuAppService.Query(getListInput);
        }

        [HttpPost("QueryByPage")]
        [SwaggerOperation(
          Summary = "分页查询列表",
          Description = "",
          OperationId = "",
          Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusView)]
        public async Task<MenuPagedResultDto> QueryByPage(MenuGetListPageInput getListPageInput)
        {
            return await MenuAppService.QueryByPage(getListPageInput);
        }

        [HttpPost("QueryCount")]
        [SwaggerOperation(
        Summary = "统计",
        Description = "",
        OperationId = "",
        Tags = new[] { "MenuManagement" }
       )]
        [Authorize(AppPlatformMenusView)]
        public async Task<long> QueryCount(MenuGetListInput getListInput)
        {
            return await MenuAppService.QueryCount(getListInput);
        }

        [HttpPost("Update/{id}")]
        [SwaggerOperation(
          Summary = "更新",
          Description = "",
          OperationId = "",
          Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusUpdate)]
        public async Task<MenuGetOutPutDto> UpdateAsync(Guid id, MenuCreateUpdateInput input)
        {
            return await MenuAppService.UpdateAsync(id, input);
        }

        [HttpPost("updateMenuEnable")]
        [SwaggerOperation(
          Summary = "更新状态",
          Description = "",
          OperationId = "",
          Tags = new[] { "MenuManagement" }
        )]
        [Authorize(AppPlatformMenusUpdate)]
        public async Task UpdateMenuEnable(MenuEnableInput input)
        {
            await MenuAppService.UpdateMenuEnable(input);
        }
    }
}
